package scau.erps.view.business.staff;


import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.DefaultTableCellRenderer;

/**
 * 业务容器模板抽象类
 * @author DCJ
 *
 */
public abstract class BusinessPanelTemplate  extends JPanel implements ActionListener{
	private static final long serialVersionUID = 1L;
	protected JComboBox<String> teamCombo,businessType,businessStatus;
	protected JButton searchBtn,approveBtn,operationBtn1,operationBtn2,operationBtn3;
	protected JPanel contentPanel,actionPanel;
	protected JScrollPane dataPanel;
	protected JTable table;
	protected DefaultTableCellRenderer render;
	public BusinessPanelTemplate(){
		teamCombo = new JComboBox<String>(new String[]{"所有小组","第1组","第2组","第3组","第4组","第5组","第6组","第7组","第8组"});
		businessType = new JComboBox<String>(); //业务类型
		businessStatus = new JComboBox<String>(); //业务状态		
		searchBtn = new JButton("筛选");
		approveBtn = new JButton("审核");
		operationBtn1 = new JButton(); //其他操作，由具体业务决定
		operationBtn2 = new JButton(); //其他操作，由具体业务决定
		operationBtn3 = new JButton(); //其他操作，由具体业务决定
		searchBtn.addActionListener(this);
		approveBtn.addActionListener(this);
		operationBtn1.addActionListener(this);
		operationBtn2.addActionListener(this);
		operationBtn3.addActionListener(this);
		actionPanel = new JPanel(); //顶部交互操作面板
		actionPanel.add(teamCombo);
		actionPanel.add(businessType);
		actionPanel.add(businessStatus);
		actionPanel.add(searchBtn);
		actionPanel.add(approveBtn);
		actionPanel.add(operationBtn1);	
		actionPanel.add(operationBtn2);
		actionPanel.add(operationBtn3);
		table = new JTable();
		table.setPreferredScrollableViewportSize(new Dimension(930, 460));
		table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		dataPanel = new JScrollPane(table);
		dataPanel.setViewportView(table);
		render = new DefaultTableCellRenderer();   
		render.setHorizontalAlignment(JLabel.CENTER);   
		table.setDefaultRenderer(Object.class,render);
		contentPanel = new JPanel();
  		contentPanel.setLayout(new BorderLayout());
		contentPanel.add(actionPanel,BorderLayout.NORTH);
		contentPanel.add(dataPanel,BorderLayout.CENTER);
		this.add(contentPanel);
	}
	/**
	 * 设置下拉框值
	 */
	public abstract void setComboItemsValue();
	
	/**
	 * 添加下拉框子项
	 * @param combo
	 * @param items
	 */
	public void addItems(JComboBox<String> combo,String[] items){
		for (int i = 0; i < items.length; i++) {
			combo.addItem(items[i]);
		}
	}
}
